<template>
  <div class="win" v-if="userData">
    <div v-if="member_type==1">
      <div class="item">
        <p class="title">门店名称</p>
        <p class="name">{{userData.store_name}}</p>
      </div>
      <div class="item">
        <p class="title">门店面积</p>
        <p class="name">{{userData.store_area}}㎡</p>
      </div>
      <div class="item">
        <p class="title">经营范围</p>
        <div class="name scope">
          <p v-for="(item, index) in userData.item" :key="index">{{item}}</p>
        </div>
      </div>
      <div class="item">
        <p class="title">门店地址</p>
        <p class="name">{{userData.address}}</p>
      </div>
      <div class="item">
        <p class="title">工位数量</p>
        <p class="name">{{userData.num}}</p>
      </div>
      <div class="item">
        <p class="title">联系方式</p>
        <p class="phone under" @click="hr_revisePhone">{{userData.phone}}</p>
      </div>
    </div>
    <div class="item" v-else>
      <p class="title">联系方式</p>
      <p class="phone under" v-if="member_type==1" @click="hr_revisePhone">{{phone}}</p>
      <p class="phone" v-else>{{phone}}</p>
    </div>
    <button @click="exitLogin">退出登录</button>
    <i-toast id="toast" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      bjurl: "",
      userData: {}, //合作商数据
      member_type: "", //缓存的用户类型1:是合作商,2:是游客
      phone: "" //缓存的手机号
    };
  },
  methods: {
    // 请求接口退出登录
    exitLogin() {
      // wx.removeStorageSync("phone");
      this.$ajax("/home/login/exitLogin", "post", {
        member_id: wx.getStorageSync("member_id")
      })
        .then(res => {
          
          if (res.status) {
            this.$toast({
              content: "退出成功"
            });
            wx.removeStorageSync("phone");
            wx.navigateBack({});
          } else {
          }
        })
        .catch(err => {});
    },
    // 请求接口账号管理列表
    getHomeList() {
      this.$ajax("/home/mine/me_list", "post", {})
        .then(res => {
          
          if (res.status) {
            this.userData = res.data;
          } else {
          }
        })
        .catch(err => {});
    },

    //跳转到修改电话
    hr_revisePhone() {
      wx.navigateTo({
        url: "../revisePhone/main"
      });
    }
  },
  onShow() {
    this.getHomeList();
    this.member_type = wx.getStorageSync("member_type");
    this.phone = wx.getStorageSync("phone");
  },
  onLoad(e) {
    Object.assign(this.$data, this.$options.data());
    this.bjurl = this.$bjurl;
  }
};
</script>

<style lang="scss" scoped>
.win {
  padding-top: 10rpx;
  .item {
    background-color: #ffffff;
    margin-bottom: 2rpx;
    width: 750rpx;
    padding: 34rpx 30rpx;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .title {
      color: #4d4d4d;
      font-size: 32rpx;
    }
    .name {
      font-size: 28rpx;
      color: $green;
      width: 540rpx;
      text-align: right;
    }
    .scope {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: flex-end;
      p {
        margin: 10rpx 0 10rpx 20rpx;
      }
    }
    .phone {
      font-size: 28rpx;
      color: $green;
      width: 460rpx;
      text-align: right;
    }
    .under {
      text-decoration: underline;
    }
  }
  button {
    color: #ffffff;
    font-size: 40rpx;
    line-height: 92rpx;
    margin: 170rpx auto 0;
    width: 500rpx;
    height: 92rpx;
    background: linear-gradient(
      0deg,
      rgba(11, 208, 94, 1),
      rgba(11, 208, 173, 1)
    );
    border-radius: 46rpx;
  }
}
</style>
